<?xml version="1.0" encoding="UTF-8" ?>
<% include '/common/headeradmin.gtpl' %>

<h1>Einträge in der Tracer Tabelle</h1>
<% include '/common/message.gtpl' %>
<br/>
<br/>
<form method="get" action="/admin/tracer">
Einträge durchsuchen nach: 
<input type="text" name="suche" value="${request.suche}"></input>
<select name="filter">
	<option value=""></option>
	<% if(params.filter == 'LOGIN') {%>
		<option selected="selected" value="LOGIN">Eingeloggt</option>
	<% } else { %>
		<option value="LOGIN">Eingeloggt</option>
	<% } %>
	<% if(params.filter == 'LOGOUT') {%>
		<option selected="selected" value="LOGOUT">Ausgeloggt</option>
	<% } else { %>
		<option value="LOGOUT">Ausgeloggt</option>
	<% } %>
	<% if(params.filter == 'ERSTELLEN') {%>
		<option selected="selected" value="ERSTELLEN">Eingestellt</option>
	<% } else { %>
		<option value="ERSTELLEN">Eingestellt</option>
	<% } %>
	<% if(params.filter == 'UPDATE') {%>
		<option selected="selected" value="UPDATE">Update</option>
	<% } else { %>
		<option value="UPDATE">Update</option>
	<% } %>
	<% if(params.filter == 'NEUER ZUGANG') {%>
		<option selected="selected" value="NEUER ZUGANG">Neuer Zugang</option>
	<% } else { %>
		<option value="NEUER ZUGANG">Neuer Zugang</option>
	<% } %>
		<% if(params.filter == 'DELETE') {%>
		<option selected="selected" value="DELETE">Delete</option>
	<% } else { %>
		<option value="DELETE">Delete</option>
	<% } %>
	
	<% if(params.filter == 'VERBOTEN') {%>
		<option selected="selected" value="VERBOTEN">Verboten</option>
	<% } else { %>
		<option value="VERBOTEN">Verboten</option>
	<% } %>
	
	<% if(params.filter == 'EMAIL') {%>
		<option selected="selected" value="EMAIL">E-Mail</option>
	<% } else { %>
		<option value="EMAIL">E-Mail</option>
	<% } %>
</select>
<input type="submit" value="Suche"></input>
</form>
<br/>
<br/>
<% def max = request.max
   int offset = request.offset
   def size = request.size
   int counter = Math.ceil(size / max) 
   int act = (Math.ceil(offset / max))+1
%>
<% if(counter > 1) {%>
<div class="paging">
	Seite ${act} von ${counter}
	<span class="paging">
	<% for (i=0; i<counter; i++) { %>
		<% def os = i*max %>
		<% if(i+1 == act) { %>
			${i+1}
		<% } else { %>
			<a class="nact" href="/admin/tracer?offset=${os}&suche=${request.suche}&filter=${request.filter}">${i+1}</a>
		<% } %>
	<% } %>
</span>
</div>
<% } %>
<br/>
<table>
  <thead>
  <tr>
  <th colspan="5">Tracer</th>
  </tr>
  <tr>
    <th class="tracer1">Datum</th>
    <th class="tracer2">Gast</th>
    <th>Typ</th>
    <th>Nachricht</th>
    <th>IP</th>
  </tr>
  </thead>
  <% request.list.each { item -> %>
  <tr> 
   <td>
   <% def date = src.de.checker.hochzeit.util.Datehelper.date2String(item.datum,'dd.MM.yyyy HH:mm') %>
      ${date}
   </td>
   <td>
   <% def username = request.usermap.get(item.user) %>
   ${username}</td>
   <td>${item.type}</td>
   <td>${item.nachricht}</td>
   <td>${item.ipadresse}</td>
  </tr>
  <% } %>
</table>
<% if(counter > 1) {%>
<div class="paging">
	Seite ${act} von ${counter}
	<span class="paging">
	<% for (i=0; i<counter; i++) { %>
		<% def os = i*max %>
		<% if(i+1 == act) { %>
			${i+1}
		<% } else { %>
			<a class="nact" href="/admin/tracer?offset=${os}&suche=${request.suche}&filter=${request.filter}">${i+1}</a>
		<% } %>
	<% } %>
</span>
</div>
<% } %>
<% include '/common/footer.gtpl' %>